package cn.itsource.pojo.enumConst;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum LevelEnum {
    BRONZE(0l,"青铜"),
    SILVER(1l,"白银"),
    GOLD(2l,"黄金"),
    PLATINUM(3l,"白金"),
    MASTER(4l,"大师"),
    GRANDMASTER(5l,"宗师"),
    KING(6l,"王者");
    private Long key;
    private String value;

    /**
     * 根据key键获取value值
     * */
    public LevelEnum getLevelEnumByKey(Long key){
        LevelEnum[] values = LevelEnum.values();
        Optional<LevelEnum> any = Arrays.stream(values).filter(item -> item.key.equals(key)).findAny();
        return any.get();
    }
}
